<style type="text/css">
.configdetail{
	margin:20px;
}
.configproperty span{
	display:inline-block;
	width:200px;
}
</style>
<script type="text/javascript">
$(document).ready(function(e) {
	$('.configdetail table span').click(function(e){
		input_edit(this,'system/config!save.action');
	});
});
var configid='${config._id}';;
function configpropertydelete(_this,p){
	var configname=$(_this).parent().prev().text();
	if(!confirm('确定删除此属性吗？')){
		return;
	}
	$.getJSON('system/config!propertyDelete.action',{id:configid,property:p},function(rs){
		if(rs.code=='1'){
			$(_this).parent().parent().remove();
		}else{
			alert(rs.msg);
		}
	});
}
function configpropertyadd(){
	if(checkForm($('.configproperty .add *[name]'))){
		var data=serializeArray($('.configproperty *[name]'));
		data.id=configid;
		$.ajax({
			url:'system/config!propertyAdd.action',
			type:'POST',
			data:data,
			dataType:"JSON",
			success: function(rs){
				if(rs.code=='1'){
					goPage('system/config!detail.action?id='+configid,'#main')
				}else{
					alert(rs.msg);
				}
			}
		});
	}
}
</script>
<div class="configdetail">
  <table class="tablestyle1">
    <caption>配置信息</caption>
    <tr>
      <th class="col2">编号</th>
      <td>${config._id}</td>
    </tr>
    <tr>
      <th class="col2">名称</th>
      <td><span type="text" regx="${check.name}" name="name" id="${config._id}">${config.name}</span></td>
    </tr>
    <tr>
      <th class="col2">描述</th>
      <td><span type="text" regx="${check.description}" name="description" id="${config._id}">${config.description}</span></td>
    </tr>
  </table>
  <table class="configproperty">
  	<tr>
    	<th>属性</th>
    	<th>值</th>
    	<th>操作</th>
    </tr>
    <#assign cokey=config.option?keys/>
    <#list cokey as key>
    <tr>	
      <th>${key}</th>
      <td><span type="text" regx="${check.value}" name="value" id="${config._id}">${config.option[key]}</span></td>
      <td><button onClick="configpropertydelete(this,'${key}')">删除</button></td>
    </tr>
    </#list>
    <tr class="add">
      <th><input type="text" name="property" regx="${check.property}" /></th>
      <td><input type="text" regx="${check.value}" name="value" /></td>
      <td><button onClick="configpropertyadd()">添加</button></td>
    </tr>
  </table>
</div>